﻿@using winproject.Controllers;

<style type="text/css">

    
</style>

<ul class="dropdown-menu multi-level disable-zindex" role="menu" aria-labelledby="dropdownMenu" style="display: block;margin-left:17px">
    @{
        
        HelperController oHelper = new HelperController();
        ReturnResult oCatResult = null;
        CategoryDetails oCatSearch = new CategoryDetails();
        List<CategoryDetails> lsCat = oHelper.GetCategoryDetails(out oCatResult, oCatSearch);
        if (oCatResult.errCode == (int)cEnums.eErrorCodes.Success)
        {
            ReturnResult oSubCatResult = null;
            SubCategoryDetails oSubCatSearch = new SubCategoryDetails();
            if(lsCat!=null && lsCat.Count>0){
                foreach(var lCat in lsCat){
                    oSubCatSearch.nParentId = lCat.nItemId;
                    List<SubCategoryDetails> lsSubCat = oHelper.GetSubCategoryDetails(out oSubCatResult, oSubCatSearch);
                    if(lsSubCat!=null && lsSubCat.Count>0){
                        <li class="dropdown-submenu">
                            <a tabindex="-1" href="Category/@lCat.sItemSlug">@lCat.sItemName</a>
                            <ul class="dropdown-menu">
                                @{
                                    foreach(var lsubCat in lsSubCat){  
                                        ReturnResult oProdResult = null;
                                        ProductDetails oProdSearch = new ProductDetails();
                                        oProdSearch.nCid = lsubCat.nParentId;
                                        oProdSearch.nSCid = lsubCat.nItemId;
                                        List<ProductDetails> lsProd = oHelper.GetProductDetails(out oProdResult, oProdSearch);
                                        if(lsProd!=null && lsProd.Count>0){
                                            <li class="dropdown-submenu">
                                                <a href="Subcategory/@lsubCat.sItemSlug">@lsubCat.sItemName</a>
                                                <ul class="dropdown-menu">
                                                @{
                                                    foreach (var lProd in lsProd)
                                                    {   
                                                        <li><a href="Products/View/@lProd.sSlug">@lProd.sTitle</a></li>
                                                    }
                                                }
                                                </ul>
                                            </li>    
                                        }
                                        else{
                                            <li><a href="Subcategory/@lsubCat.sItemSlug">@lsubCat.sItemName</a></li>
                                        }
                                        @*<li class="divider"></li>*@
                                    }
                                }
                            </ul>
                         </li>
                    }
                    else{
                        <li><a href="Category/@lCat.sItemSlug">@lCat.sItemName</a></li>
                    }
                    @*<li class="divider"></li>*@
                }
            }
            
        }
    }
</ul>
